
****************** EVI MEASURES - APPENDIX TABLE 

use "$data/yield_cell_input.dta", clear

drop if year < 2002 
drop if year > 2017

// generate period identifier 
cap drop t
egen t = group(year)


preserve

	collapse (mean) total_yield_idt evi_delta_k evi_max_k  evi_cumul_k, by(district_MCA_s t)

	foreach s in k {
					foreach var in evi_delta_`s' evi_max_`s' evi_cumul_`s' {
						g ln_`var'= ln(`var')
					}
				}

	local replace replace
	reghdfe total_yield_idt ln_evi_delta_k, a(i.district_MCA_s i.t) cluster(district_MCA_s) 
	local replace append
	binscatter 	total_yield_idt ln_evi_delta_k, absorb(district_MCA_s) ytitle(Yield) xtitle(log(EVI Delta)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
	graph export "$results/graphs/figure_A3_a.pdf", replace 
	
	reghdfe total_yield_idt ln_evi_max_k, a(i.district_MCA_s i.t) cluster(district_MCA_s)
	binscatter 	total_yield_idt ln_evi_max_k, absorb(district_MCA_s) ytitle(Yield) xtitle(log(EVI Max)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
	graph export "$results/graphs/figure_A3_b.pdf", replace 
	reghdfe total_yield_idt ln_evi_cumul_k, a(i.district_MCA_s i.t) cluster(district_MCA_s)
	binscatter 	total_yield_idt ln_evi_cumul_k, absorb(district_MCA_s) ytitle(Yield) xtitle(log(EVI Cum.)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
	graph export "$results/graphs/figure_A3_c.pdf", replace 

restore

keep if cells_50km_stateborders == 1 

local replace replace
reghdfe total_yield_idt ln_evi_delta_k, a(i.id i.t) cluster(id)
binscatter 	total_yield_idt ln_evi_delta_k, absorb(id)  ytitle(Yield) xtitle(log(EVI Delta)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
graph export "$results/graphs/figure_A4_a.pdf", replace 
local replace append
reghdfe total_yield_idt ln_evi_max_k, a(i.id i.t) cluster(id)
binscatter 	total_yield_idt ln_evi_max_k, absorb(id)  ytitle(Yield) xtitle(log(EVI Max)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
graph export "$results/graphs/figure_A4_b.pdf", replace 
reghdfe total_yield_idt ln_evi_cumul_k, a(i.id i.t) cluster(id)
binscatter 	total_yield_idt ln_evi_cumul_k, absorb(id)  ytitle(Yield) xtitle(log(EVI Cum.)) graphregion(color(white) lwidth(none)) mcolor(black) msymbol(circle_hollow) lcolor(blue) ylabel(,nogrid) 
graph export "$results/graphs/figure_A4_c.pdf", replace 





